<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理员登录 - 管理后台</title>
    <link rel="stylesheet" href="/static/admin/layui/css/layui.css">
    <style>
        html {
            background-image: url("/static/admin/image/background.jpg");
        }
        .pane {
            width: 550px;
            height: 250px;
            border-radius: 5px;
            margin: 0 auto;
            margin-top: 250px;
            background: rgba(0,0,0,0.3);
        }
        .form_left {
            float: left;
            color: #fff;
            font-size: 20px;
            background: url(/static/admin/image/2864265402763801.png) no-repeat;
            background-size: 150px 100px;
            background-position: 5px 60px;
            height: 300px;
            padding: 100px 20px 0;
            margin-left: 30px;
        }
        .form_right {
            float: left;
            margin-left: 50px;
            width: 50%;
        }
        .layui-form {
            margin-top: 50px;
        }
        .layui-form-label {
            width: 50px !important;
        }
        .layui-input-block {
            margin-left: 50px !important;
        }
    </style>
</head>
<body>
<div class="main">
    <div class="pane">
        <div class="form_left">商城后台系统</div>
        <div class="form_right">
            <form class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="username" placeholder="用户名">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                    <div class="layui-input-block">
                        <input type="password" class="layui-input" name="password" placeholder="密码">
                    </div>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid layui-btn-normal" id="submit">登录</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="/static/admin/layui/layui.js"></script>
<script>
    layui.use(['layer'], function () {
        var layer = layui.layer;
        var $ = layui.jquery;

        // 登录
        $("#submit").click(function () {
            $.ajax({
                url: "/admin/login",
                type: "post",
                data: $("form").serialize(),
                dataType: "json",
                success: function (ret) {
                    if (ret.code == 1) {
                        layer.msg(ret.msg, {time: 2000}, function () {
                            window.location.href = "/admin/index";
                        });
                    } else {
                        layer.msg(ret.msg);
                    }
                },
                error: function(err){
                    console.log(123132);
                    console.log(JSON.stringify(err))
                }
            });
            return false;
        });
    });
</script>
</body>
</html>